/**
 * @Author: 焦质晔
 * @Date: 2019/6/20
 * @Last Modified by: mikey.zhaopeng
 * @Last Modified time: 2019-12-20 13:32:59
 */
import axios from '@/api/fetch';
import * as types from './types';
import SERVER from '@/api/server';

// 查询员工信息(员工权限编辑页面)
export const searchRoleEmp = params => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/basedata/employees/permission/items`, { params });
//新接口--李贺
export const searchEmployee = params => axios.post(`${SERVER.DMSCLOUD_BASEDATA}/basedata/employees/employees` , params);
// 管理员锁定账户
export const lockflag = id => axios.post(`${SERVER.DMSCLOUD_BASEDATA}/basedata/employees/lock/${id}`, { id: Number(id) });
// 管理员解锁账户
export const removeLockflag = id => axios.post(`${SERVER.DMSCLOUD_BASEDATA}/basedata/employees/removelock/${id}`, { id: Number(id) });
export const userDataVue = id => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/basedata/users/userDataVue/${id}`, id);
// 根据id查找员工信息
export const findByEmployeeId = id => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/basedata/employees/epmloyee/${id}`, { id: Number(id) });
// 获取职位角色
export const findEmployeeRoleById = id => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/basedata/employees/findEmployeeRoleById/${id}`, { id: Number(id) });
// 获取职位角色测试环境
export const findTcCodeByType = id => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/basedata/employees/findTcCodeByType/${id}`, { id: Number(id) });
//保存
export const savePermission = params => axios.put(`${SERVER.DMSCLOUD_BASEDATA}/basedata/users/permission`, params);
// 修改密码
export const supereditpassword = params => axios.put(`${SERVER.DMSCLOUD_BASEDATA}/basedata/users/supereditpassword`, params);
// 查询职位
export const orgPosition = params => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/basedata/orgPosition`, { params });
//职位模板保存
export const positionData = (params = {}) => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/basedata/orgPosition/positionData/${params}`);

//编辑查询数据
export const getEmployeeInfo = employeeNo => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/basedata/employees/emp?employeeNo=${employeeNo}`);
//编辑保存
export const postEmployeeInfo = params => axios.put(`${SERVER.DMSCLOUD_BASEDATA}/basedata/employees/employee`, params);

//获取角色
// export const getRole = (params) => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/basedata/employees/role`)
export const getRole = (employeeNo, orgId, isAdd, params) => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/basedata/employees/role?employeeNo=${employeeNo}&orgId=${orgId}&isAdd=${isAdd}`);
//获取配置权限信息
export const getEmployeeNo = params => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/basedata/employees/position`, {params});
//新增职位
export const confirmRole = params => axios.post(`${SERVER.DMSCLOUD_BASEDATA}/basedata/employees/role`, params);
//获取RoleId
export const getRoleId = (userOrgId, params) => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/basedata/employees/roleId?userOrgId=${userOrgId}`);
//根据用户的userOrgId查询责任线索来源
export const findClueSourceids = userOrgId => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/basedata/employees/findClueSourceids?userOrgId=${userOrgId}`);
//获取getRoleData
export const getRoleData = (roleId, params) => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/basedata/roles/roleData?roleId=${roleId}`);
//获取树
export const userPermission = (userOrgId, dataSource) => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/basedata/users/userPermission/${userOrgId}/${dataSource}`);

//新增保存
export const saveEmployee = params => axios.post(`${SERVER.DMSCLOUD_BASEDATA}/basedata/employees/employee`, params);

//重置密码
export const editPassword = (employeeNo, password) => axios.post(`${SERVER.DMSCLOUD_BASEDATA}/basedata/userInfo/resetPassword?employeeNo=${employeeNo}&&password=${password ? password : ''}`);

//职位查询
export const getUserOrgId = userOrgId => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/basedata/employees/role2?userOrgId=${userOrgId}`);
//删除
export const deleteUserOrgId = userOrgId => axios.delete(`${SERVER.DMSCLOUD_BASEDATA}/basedata/employees/userOrg?userOrgId=${userOrgId}`);
//保存
export const saveRolePermission = params => axios.put(`${SERVER.DMSCLOUD_BASEDATA}/basedata/employees/permission`, params);

//工位查询接口
export const maintainWorkType = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/maintainWorkType/dicts/select`);
//班组查询接口
export const workGroups = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/workgroups/dicts/select`, params);

// 获取价格权限数据
export const userPriceJurisdiction = userOrgId => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/basedata/users/userPriceJurisdiction?userOrgId=${userOrgId}`);
